import 'package:flutter/material.dart';


void main() {

  runApp(new MyApp());

  tabBarData.forEach((f) => print(' wy : wwwwwww')) ;
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new MaterialApp(

      home: new HomePage(),
    );
  }
}


class HomePage extends StatelessWidget {
  
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(

      length: tabBarData.length,

      child: Scaffold(

        appBar: new AppBar(

          title: new Text('TabBarDemo'),
          bottom: new TabBar(

              tabs: tabBarData.map((TabBarBean tabData) {
                return new Tab(

                  text: tabData.text,

                  icon: new Icon(tabData.iconData),

                );
              }).toList()

          ),

        ),

        body: new TabBarView(

            children: tabBarData.map((TabBarBean tabBarViewData) {
              return new Padding(

                padding: EdgeInsets.all(16),
                child: new TabBarSelectView(tabBarViewData),

              );
            }).toList()

        ),
      ),
    );
  }
}


List<TabBarBean> tabBarData = [

  new TabBarBean('1', Icons.directions_bike),
  new TabBarBean('2', Icons.directions_bike),
  new TabBarBean('3', Icons.directions_bike),
  new TabBarBean('4', Icons.directions_bike),

];

class TabBarBean {

  String text;

  IconData iconData;

  TabBarBean(this.text, this.iconData);

}





class TabBarSelectView extends StatelessWidget {

  final TabBarBean tabBarBean;

  const TabBarSelectView(this.tabBarBean);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Card(

      child: new Column(


        crossAxisAlignment: CrossAxisAlignment.center,
//
        mainAxisSize: MainAxisSize.max,

        children: <Widget>[


          new Text(tabBarBean.text),

          new Icon(tabBarBean.iconData),

        ],
      ),

    );
  }
}